package config

import (
	"github.com/spf13/viper"
)

type DbConfigs map[string]*DatabaseConfig

type DatabaseConfig struct {
	Type     string `yaml:"type"`
	Host     string `yaml:"host"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	DbName   string `yaml:"dbname"`
	Port     uint   `yaml:"port"`
}

func GetDBConfigData(type_name string) *DatabaseConfig {
	return &DatabaseConfig{
		Type:     viper.GetString(type_name + ".type"),
		Host:     viper.GetString(type_name + ".host"),
		User:     viper.GetString(type_name + ".user"),
		Password: viper.GetString(type_name + ".password"),
		DbName:   viper.GetString(type_name + ".dbname"),
		Port:     viper.GetUint(type_name + ".port"),
	}
}
